define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resume/resume/index',
                    del_url: 'resume/resume/del',
                    edit_url: 'resume/resume/edit',
                    multi_url: 'resume/resume/multi',
                    table: 'user_resume',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'resume_id',
                sortName: 'resume_id',
                columns: [
                    [
                        {field: 'user_id', title: __('User_id')},
                        {field: 'name', title: __('Name')},
                        {field: 'age', title: __('Age'), operate:false},
                        {field: 'photo', title: __('Photo'), operate:false, formatter: Table.api.formatter.image},
                        {field: 'sex', title: __('Sex'), operate:false},
                        {field: 'birthday', title: __('Birthday'), operate:false},
                        {field: 'origin', title: __('Origin'), operate:false},
                        {field: 'edu', title: __('Edu'), operate:false},
                        {field: 'tel', title: __('Tel'), operate:false},
                        {field: 'spare_tel', title: __('Spare_tel'), operate:false},
                        {field: 'wechat', title: __('Wechat'), operate:false},
                        {field: 'qq', title: __('Qq'), operate:false},
                        {field: 'addr', title: __('Addr'), operate:false},
                        {field: 'job_status', title: __('Job_status') ,formatter: Table.api.formatter.status, searchList: __('Job_statusa'), style: 'min-width:100px;'},
                        {field: 'job_type', title: __('Job_type'), operate:false},
                        {field: 'target_work', title: __('Target_work'), operate:false},
                        {field: 'working_age', title: __('Working_age'), operate:false},
                        {field: 'cuisine', title: __('Cuisine'), operate:false},
                        {field: 'remuneration', title: __('Remuneration'), operate:false},
                        {field: 'start_time', title: __('Id_number'), operate:false},
                        {field: 'end_time', title: __('Id_number_img'), operate:false},
                        {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: __('Statusa'), style: 'min-width:100px;',
                        	formatter: function(value,data,ret){
                        		if(value=='已通过'){
                        			return "<a href='javascript:void(0);' user_id="+data.resume_id+" style='color:green;cursor: pointer;display:block;' class='status'>已通过</a>";
                        		}else{
                        			return "<a href='javascript:void(0);' user_id="+data.resume_id+" style='color:#e74c3c;cursor: pointer;display:block;' class='status'>未通过</a>";
                        		}
                        	}
                        },
                        {
                            field: 'operate',
                            title: __('Operate'),
                            width: "120px",
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name:'url',
                                    text:'',
                                    icon: 'fa fa-anchor',
                                    classname: 'btn btn-info btn-xs btn-dialog',
                                    url: 'wx/amoy/resume_url'
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ],
                showToggle: false,
                showColumns: false,
                search:false,
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
            $(document).on("click", ".status", function(){
                var id=$(this).attr('user_id'),
                    text =$ (this).text(),
                    thiss = $(this);
                Fast.api.ajax('resume/resume/change_status/ids/'+id,
                function(value,data,res){
                	if(data.code==1){
                		layer.alert(data.msg,function(){
                            if(text=='未通过'){
                                thiss.text('已通过');
                                thiss.css("color","green");
                                layer.closeAll();
                            }else{
                                thiss.text('未通过');
                                thiss.css("color","#e74c3c");
                                layer.closeAll();
                            }
                		});
                	}else{
                		layer.alert(data.msg);
                	}
                    Fast.api.close();
                });
            });
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
        },
        
    };
    return Controller;
});